package com.panshi.modules.controller;


import com.panshi.modules.service.SysFeedbackService;
import com.panshi.vo.R;
import com.panshi.vo.SysFeedback;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器 : 反馈表
 * </p>
 *
 * @author 857
 * @since 2020-07-29
 */
@Api(tags = "反馈接口")
@CrossOrigin
@RestController
@RequestMapping("/api/sys/feedback")
public class SysFeedbackController {

    @Autowired
    private SysFeedbackService sysFeedbackService;

    @GetMapping("/list")
    @ApiOperation("查找反馈集合接口")
    public List<SysFeedback> listSysFeedback(){
        return sysFeedbackService.listSysFeedback();
    }

    @GetMapping("/{id}")
    @ApiOperation("ID获取反馈内容接口")
    public SysFeedback getSysFeedback(@PathVariable("id") Integer id) {
        return sysFeedbackService.getSysFeecback(id);
    }

    @PostMapping
    @ApiOperation("新增反馈信息接口")
    public R addSysFeedback(@RequestBody SysFeedback sysFeedback){
        int result = sysFeedbackService.addSysFeedback(sysFeedback);
        if(result > 0){
            return R.ok();
        }
        return R.error();
    }

    @PutMapping
    @ApiOperation("编辑反馈接口")
    public R editSysFeedback(@RequestBody SysFeedback sysFeedback){
        int result = sysFeedbackService.editSysFeedback(sysFeedback);
        if(result > 0){
            return R.ok();
        }
        return R.error();
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除反馈信息接口")
    public R delSysFeedback(@PathVariable("id")Integer id){
        int result = sysFeedbackService.delSysFeedback(id);
        if(result > 0){
            return R.ok();
        }
        return R.error();

    }
}

